package com.haiertvbic.tvwa.util;

import android.os.Process;

import com.haiertvbic.tvwa.model.SingleHandler;

public class ProduceThread {
	
	public static  int seconds = 30;
	public static boolean canRun = true;
	public static boolean exit = true;
	public static void produceThread(final SingleHandler sHandler) {
		new Thread(){
			@Override
			public void run() {
				super.run();
					while(seconds>0&&canRun){
						sHandler.sendEmptyMessage(seconds);
						seconds--;
						if (seconds == 0) {
							exit = true;
						}
						try {
							Thread.sleep(1000);
						} catch (InterruptedException e) {
							e.printStackTrace();
						}
					}
					
					if(exit){
						for(int i = 0;i < AppManager.activityList.size();i++){
							AppManager.activityList.get(i).finish();
						}
					}
				seconds = 30;
				canRun = true;
				
			}
		}.start();
	}

}
